package com.czq.zk2.metas;

/**
 * @author jiusan
 */

import com.fasterxml.jackson.annotation.JsonValue;

import java.util.*;

/**
 * 1、构造私有
 * 2、都是继承 Enum类
 * name    当前枚举名字
 * ordinal 下标 从0开始
 * 3、JsonValue 序列化
 */
public enum SexEnum {
    MAN(0, "男"),
    WOMAN(1, "女");

    private int code;

    @JsonValue
    private String msg;

    private SexEnum(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public int getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    public static List<Map<String, Object>> getSexes() {
        List<Map<String, Object>> result = new ArrayList<>();
        for (SexEnum value : values()) {
            HashMap<String, Object> map = new HashMap<>();

            map.put("index", value.ordinal());
            map.put("msg", value.getMsg());

            result.add(map);
        }

        return result;
    }
}
